\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}

\usepackage{indentfirst}
\parskip=12pt % adds vertical space between paragraphs

\title{Macro model}

\author{Ricardo Cruz}

\date{\today}

\begin{document}
\maketitle

\begin{abstract}
Draft of our model as we go ...
\end{abstract}

\section{Introduction}

Based on a model by Dosi et al \cite{italianos2005}, this is a description of our work and model, as we go along. We have two types of firms: firms that produce \textbf{capital-goods}, and firms that produce \textbf{consumer goods}. Capital-goods are bought by consumer-goods firms. Consumer goods are bought by consumers. Consumers are all the same, and their consumption comes from wages (depending on labor demand by capital and consumer firms), but there is always a residual demand for consumer goods as well (we can consider it a government unemployment). Consumer-goods production firms must forecast the demand by consumers (\textbf{consumption}); capital-goods do not need to forecast demand (\textbf{investment}) by consumer-goods firms (they produce as requested by consumer-goods firms).

The structure of our economy as agents:

\renewcommand{\arraystretch}{2}
\begin{tabular}{|l|}
	\hline
	capital-goods firms (kfirms) \\\hline
	consumer-goods firms (cfirms) \\\hline
	consumers \\\hline
\end{tabular}
\renewcommand{\arraystretch}{1}

\section{Simulation steps}

We structure simulation in the following steps. The structure of the simulation resembles the aforementioned article. I don't know why I tweaked it; I think it was mostly unintentional.

\begin{enumerate}
\item update cfirms: consumer firms make decisions regarding how much to produce and invest
\item update kfirms: capital firms take care of any orders they may have
\item update cfirms market share: consumer firms are punished if they raise prices (in other words, if their capital costs are too high, since prices follow a mark-up rule) or if they could not fulfill all consumer demand
\item update kfirms market share: identical
\item kfirms innovate, and firms may go out of business if they have no market share
\item macro dynamics; aggregates are calculated here; demand of consumer products is computed by partioning incomes by market share
\end{enumerate}

\section{Agents states}

Note: each variable is indexed by time.

cfirm

\begin{tabular}{|l|l|l|}
	\hline
	\textbf{Variable} & \textbf{Description} & \textbf{For $t=0$} \\\hline\hline
	p & price practiced & (does not matter) \\\hline
	A & capital owned by the firm & empty list \\\hline
	LD & people employed & 0 \\\hline
	D & demand at time $t$ & 0 \\\hline
	S & sold: $S(t)=Min\{D(t),Q(t)\}$ & (does not matter) \\\hline
	Q & quantity produced & 0 \\\hline
	N & inventory (unsold goods) & 0 \\\hline
	NW & net worth & 3000 \\\hline
	I & investment & 0 \\\hline
	x & relative market share & $1/nfirms$ \\\hline
\end{tabular}

kfirm

\begin{tabular}{|l|l|l|}
	\hline
	\textbf{Variable} & \textbf{Description} & \textbf{For $t=0$} \\\hline\hline
	p & price practiced & (does not matter) \\\hline
	A & productivity of most recent model & 1 \\\hline
	LD & people employed & 0 \\\hline
	D & demand at time $t$ & 0 \\\hline
	Q & quantity produced & 0 \\\hline
	NW & net worth & 3000 \\\hline
	x & relative market share & $1/nfirms$ \\\hline
\end{tabular}

Notice how capital-goods firms do not have sold or inventory variables (since they produce as orders come in), nor do they have investment.

\section{Step 1: update cfirms}

Expected demand $De$ is computed as described in \ref{De}, and quantity desired for production is this expected demanded minus what we have in inventory:

$$Qd = De - N$$

A set of the productivity of the stock of capital owned is represented by $A=\{A_0, \ldots, A_K\}$, so $K$ is the total stock of capital.

As for how much money the firm wants to put behind production or investment, I am still working out the details. I think I will need to look up the literature. It seems to me this should be the result of an optimization process, where each firm wants to:

\begin{quote}\begin{quote}
\begin{tabular}{ll}
	Maximize & $longterm\_profit = sum_{t=0}^{\infty} r^t \cdot profit(t)$ \\
	Subject to & $NW > 0$ \\
    & and etcetera
\end{tabular}
\end{quote}\end{quote}

I have played with some simple decision making processes as of now.

\subsection{Scenario 1: can borrow for production}
\label{scenario1}

For \textbf{production}, the money firm $can\_spend = NW + can\_borrow$, and I have used $can\_borrow=3000$. Production is restrained by amount of capital as in:

$$Q = min\{K,Qd\}$$

(Not sure, as in the article, we will want to have an $ud$ under-used capital coefficient.)

Then total cost of production is given by:

$$Qc = Q \cdot c$$, where $c = \frac{wage}{\bar{A}}$

Number of employed people is given by:

$$LD = \frac{Q}{\bar{A}}$$

Price is given by a markup rule:

$$p = (1+\mu) \cdot c$$

For \textbf{investment}, $can\_spend = NW - Qc$, and no borrowing is allowed. The reason for this is so we do not end up in a trap where we have the capital, but cannot produce anything because we are out of liquidity, and our firms are not smart enough to sell off capital. In effect, what we call $can\_borrow$ is merely a label for a threshold on spending in investment; we do have in the simulation code dealing with interest rates associated with the borrowing of money, but the effect of this in the simulation is largely immaterial, and it might make sense to simplify and remove debt altogether from the model, in favor of a threshold rule (if we do want to keep such a simple decision making process).

Desired capital is given by:

$$Kd = \frac{Qd}{ud}$$

And to force lumpy decision making, we have a trigger after which investment happens:

$$Ktrig = K \cdot (1 + \alpha)$$

Expansion investment is $EI = Kd$ only when $Kd \geq Ktrig$, otherwise $EI=0$.

The scrap rule for removing machines is the same as in the article \cite{italianos2005}, and I will not describe it here.

The values we use when investing are the averages of prices $\bar{p}$ and productivities $\bar{A}$ of the machines being sold in the market. The article did not detail what the authors have done here. I do not take in consideration the market share of capital firms for now (we probably should do so). In a latter article, Dosi et al \cite{italianos2008}, allow for a searching menu of the machines available (with imperfect information)...

For reasons such as this (cfirms buying "average" capital, and not from specific firms), cfirms do not behave as heterogeneous agents.

In the end, the accounting is done:

$$NW = NW + (p \cdot S) - Qc - (r \cdot Deb) - I$$
, where $Deb = -min\{0,NW\}$

Under this scenario what happens is this:

\begin{figure}[ht!]
\centering
\includegraphics[scale=0.75]{agg.png}
\caption{Aggregate variables from scenario 1; see \ref{scenario1}.}
\end{figure}

$t=1$ a empresa não pode produzir: gasta o que pode em capital (isto aumenta emprego $=>$ aumenta consumo)

$t=2$ com $NW=0$, a empresa endivida-se para produzir (não pode produzir muito) (já não há investimento, diminui consumo)

$t=3$ uma vez que o consumo é menor, (apesar de dar prioridade à produção) empresa consegue produzir e investir um pouco (mais investimento $=>$ mais emprego $=>$ mais consumo)

$t=4$ voltamos ao $t=2$, embora agora com mais stock de capital

Este processo continua até estabilizar-se com um sobre-investimento, porque parte da produção tinha sido induzido pela procura dos trabalhadores do investimento ..

\subsection{Scenario 2: no production costs}

There are no production costs. This does not seem to impact the simulation. (for obvious reasons, in fact; it just means firms have more money for investing, and there is more money in the economy so the simulation just runs faster.)

\section{Step 2: update kfirms}

$c = \frac{wage}{A}$

Marginal cost is assumed to be inversely proportional to the productivity of the model. I did ask the corresponding author about this when I first read the paper. His reply:

\begin{quote}
Dear Ricardo in the paper you are reading we make the simplifying and quite heroic) assumption that the productivity OF the machine and the productivity IN the Production of the machine are the same. Go to the "schumpeter meeting Keynes .." paper (JEDC,2010) for the abandonement of the assumption.
\end{quote}

$$p = (1 + \mu) \cdot c$$

$$LD = \frac{Q}{A}$$

$$NW = NW + ((p - c) \cdot Q) - (r \cdot Deb)$$
, where $Deb = -min\{0,NW\}$

\section{Step 3: update consumption-goods market}

The relative market share $x$ follow a dynamic described below at \ref{marketshare}.

\begin{figure}[ht!]
\centering
\includegraphics[scale=0.75]{shares.png}
\caption{Under the current simulation, the agents act as a single representative agents; market share does not change for any.}
\end{figure}

\section{Step 4: update capital-goods market}

See previous section.

\section{Step 5: exit and update innovation}

With a probability of $\frac{1}{2}$, capital-goods firms innovate the productivity of their machines by $A = A + [0,0.5]$.

Firms "die" when their market share goes to zero. In our simulation, this only happens for some capital-goods firms, because our consumer-goods firms behave as a representative agent for now, as described before.

\section{Step 6: macro dynamics}

Unlike in the article, I don't let labor force grow, or wage. Employment is the sum of labor demands, limited by labor supply $L$:

$$Emp = Min\{\sum_{i \in cfirms} LD_i + \sum_{i \in kfirms} LD_i, L\}$$

Consumption is given by:

$$C = (wage \cdot Emp) + (\phi \cdot wage \cdot L)$$

And for each cfirm $i$, consumption is translated into demand as in:

$$D_i(t) = C(t) \cdot x_i(t)$$
$$S_i(t) = \min\{D_i(t),Q_i(t)\}$$
$$N_i(t+1) = Q_i(t)-S_i(t)$$

As for kfirms,

$$D_i = I_i \cdot x_i$$

\section{Model details}

\subsection{Expected demand (cfirms)}
\label{De}

We do not try anything fancy here

$$D_e(t) = D(t-1)$$

\subsection{Market share computation (cfirms and kfirms)}
\label{marketshare}

Firms are punished based on certain criteria (from a fitness function). I follow the difference equation from Dosi \cite{italianos2005}. It says this is a replicator equation, though I do not recognize it as such. We should put further study into this dynamic.

$$\Delta x_i = x_i \cdot 0.5 \cdot \frac{f_i - \bar{f}}{\bar{f}}$$

, where $x_i$ is the relative market share of firm $i$, $f_i$ is the result of a fitness function (the higher the better), and $\bar{f}$ the average of these fitness functions. We make sure $\sum_i x_i = 1$.

The fitness is a sum of penalizations. For cfirms:

$$f_i = - p_i - (D_i-S_i)$$
, where $p_i$ is price practiced by firm $i$, and $D_i-S_i$ is unfulfilled demanded.

For pfirms:

$$f_i = - p_i + A_i$$
, where $p_i$ is price practiced by firm $i$, and $A_i$ is the productivity of its more recent machine (products produced for one period of labor input).

\begin{thebibliography}{9}

\bibitem{italianos2005}
  Giovanni Dosi, Giorgio Fagiolo \& Andrea Roventini,
  \emph{An Evolutionary Model of Endogenous Business Cycles}.
  Computational Economics, 2005.

\bibitem{italianos2008}
  Giovanni Dosi, Giorgio Fagiolo \& Andrea Roventini,
  \emph{The microfoundations of business cycles: an evolutionary, multi-agent model}.
  Journal of Evolutionary Economics, 2005.

\end{thebibliography}

\end{document}
